
********************************************************************************
********************************************************************************
**** FIGURE 2 & FIGURE 3  ******************************************************
********************************************************************************
********************************************************************************

use  "${data}Panel_quarterly.dta", replace


keep if roundPBD_sample==1

**************************************
**** without FE **********************
**************************************

capture program drop Graph_withoutFE
program Graph_withoutFE



set more off

global coeflist "quarter_1 quarter_2 quarter_3 quarter_4 quarter_5 quarter_6 quarter_7 quarter_8 quarter_9 quarter_10 quarter_11 quarter_12 quarter_13"

preserve
keep if  PBD==0 ${cond}
xi : reg ${var} ${coeflist} if  PBD==0, nocons  vce(cluster spell_identifier)  
est store m0
restore

preserve
keep if  PBD==6 ${cond}
xi : reg ${var} ${coeflist} if  PBD==6, nocons  vce(cluster spell_identifier)  
est store m1
restore

preserve
keep if  PBD==12 ${cond}
xi : reg ${var} ${coeflist}  if  PBD==12, nocons vce(cluster spell_identifier)  
est store m2
restore

preserve
keep if   PBD==24 ${cond}
xi : reg ${var} ${coeflist}  if   PBD==24, nocons  vce(cluster spell_identifier)  
est store m4
restore

preserve
keep if  PBD==36  ${cond}
xi : reg ${var} ${coeflist} if  PBD==36, nocons  vce(cluster spell_identifier)  
est store m5

restore



coefplot 	(m0, color(black) msymbol(none)  label("no UI") keep(${coeflist}) lpattern(solid) lwidth(0.7) ) ///
			(m1, color(orange) msymbol(none)  label("6") keep(${coeflist}) lpattern(solid) lwidth(0.7) ) ///
			(m2, color(red) msymbol(none) label("12") keep(${coeflist}) lpattern(solid) lwidth(0.7))  ///
			(m4, msymbol(none) color(purple)label("24") keep(${coeflist}) lpattern(solid) lwidth(0.7)) ///
			(m5, msymbol(none) color(blue)label("36 months") keep(${coeflist}) lpattern(solid) lwidth(0.7)) , /// 
			xline(3,lcolor(orange) lpattern(dash)) xline(5,lcolor(red)lpattern(dash)) ///
			xline(9,lcolor(purple) lpattern(dash)) xline(13,lcolor(blue) lpattern(dash))  ///
			order(${coeflist})     xlabel(3 "6 "  5 "12 "   9 "24 " 13  "36 ", labsize(large))   ${yscale}  nooffsets ///
			vertical ${yscale}  levels(90) scheme(s1mono) noci   connect(direct)  ytitle("  ")   xtitle("Time of Unemployment spell", size(large)) legend(off)
graph export "Figure2_${Figure2num}.png", replace	


end




******************************************************************************************************************************
***** with individual FE *****************************************************************************************************
******************************************************************************************************************************


capture program drop Graph_withFE
program Graph_withFE

global coeflist "zero quarter_2 quarter_3 quarter_4 quarter_5 quarter_6 quarter_7 quarter_8 quarter_9 quarter_10 quarter_11 quarter_12 quarter_13"


     
set more off

preserve
keep if  PBD==0 ${cond}
xi : reghdfe ${var} ${coeflist}  , absorb(spell_identifier)  vce(cluster spell_identifier)  
est store m10
restore

preserve
keep if  PBD==6 ${cond}
xi : reghdfe ${var} ${coeflist}  , absorb(spell_identifier)  vce(cluster spell_identifier)  
est store m11
restore

preserve
keep if PBD==12 ${cond}
xi : reghdfe ${var} ${coeflist}   , absorb(spell_identifier)  vce(cluster spell_identifier)  
est store m12
restore

preserve
keep if  PBD==24  ${cond}
xi : reghdfe ${var} ${coeflist}   , absorb(spell_identifier)  vce(cluster spell_identifier)  
est store m14
restore

preserve
keep if  PBD==36  ${cond}
xi : reghdfe ${var} ${coeflist}   , absorb(spell_identifier)  vce(cluster spell_identifier)  
est store m15
restore




coefplot 	(m10, color(black) msymbol(none)  label("no UI") keep(${coeflist}) lpattern(solid) lwidth(0.7) ) ///
			(m11, color(orange) msymbol(none)  label("6") keep(${coeflist}) lpattern(solid) lwidth(0.7) ) ///
			(m12, color(red) msymbol(none) label("12") keep(${coeflist}) lpattern(solid) lwidth(0.7))  ///
			(m14, msymbol(none) color(purple)label("24") keep(${coeflist}) lpattern(solid) lwidth(0.7)) ///
			(m15, msymbol(none) color(blue)label("36 months") keep(${coeflist}) lpattern(solid) lwidth(0.7)) ,  omitted /// 
			xline(3,lcolor(orange) lpattern(dash))  xline(5,lcolor(red)lpattern(dash)) xline(9,lcolor(purple) lpattern(dash)) xline(13,lcolor(blue) lpattern(dash))  ///
			order(${coeflist})    xlabel(3 "6 "  5 "12 "   9 "24 " 13  "36 ", labsize(large))    nooffsets ///
			yline(0, lstyle(major_grid)) ${yscale}  vertical  levels(90) scheme(s1mono) noci  legend(off)  connect(direct)  ytitle("  ")  xtitle("Time of Unemployment spell", size(large))  
graph export "Figure2_${Figure2num}.png", replace	


coefplot 	(m10, color(black) msymbol(none)  label("no UI") keep(${coeflist}) lpattern(solid) lwidth(0.7) ciopts(recast(rconnected) lcolor(black) lpattern(line) lwidth(thin)   msymbol(none)  )  ) ///
			(m11, color(orange) msymbol(none)  label("6 months UI") keep(${coeflist}) lpattern(solid) lwidth(0.7) ciopts(recast(rconnected) lcolor(orange) lpattern(line) lwidth(thin)   msymbol(none)  ) ) ,  omitted ///
			xline(3,lcolor(orange) lpattern(dash))  xlabel(3 "6"  5 "12" 7 "18"  9 "24" 11 "30"  13  "36", labsize(large))  order(${coeflist})     nooffsets ///
			yline(0, lstyle(major_grid)) ${yscale}  vertical  levels(95) scheme(s1mono)  legend(off)  connect(direct)   ytitle("${ytitle2}", size(large))   
graph export "Figure3_${Figure3num}_6months.png", replace	

coefplot 	(m10, color(black) msymbol(none)  label("no UI") keep(${coeflist}) lpattern(solid) lwidth(0.7) ciopts(recast(rconnected) lcolor(black) lpattern(line) lwidth(thin)   msymbol(none)  )  ) ///
			(m12, color(red) msymbol(none) label("12 months UI") keep(${coeflist}) lpattern(solid) lwidth(0.7) ciopts(recast(rconnected) lcolor(red) lpattern(line) lwidth(thin)   msymbol(none)  ) ) ,  omitted ///
			xline(5,lcolor(red)lpattern(dash)) xlabel(3 "6"  5 "12" 7 "18"  9 "24" 11 "30"  13  "36", labsize(large))  order(${coeflist})    nooffsets ///
			yline(0, lstyle(major_grid)) ${yscale} vertical  levels(95) scheme(s1mono)  legend(off)  xtitle("Time of Unemployment spell", size(large))  connect(direct)  ytitle("${ytitle2}", size(large))   
graph export "Figure3_${Figure3num}_12months.png", replace	


coefplot 	(m10, color(black) msymbol(none)  label("no UI") keep(${coeflist}) lpattern(solid) lwidth(0.7) ciopts(recast(rconnected) lcolor(black) lpattern(line) lwidth(thin)   msymbol(none)  )  ) ///
			(m14, msymbol(none) color(purple)label("24 months UI") keep(${coeflist}) lpattern(solid) lwidth(0.7) ciopts(recast(rconnected) lcolor(purple) lpattern(line) lwidth(thin)   msymbol(none)  ) ) ,  omitted ///
			 xline(9,lcolor(purple) lpattern(dash)) xlabel(3 "6"  5 "12" 7 "18"  9 "24" 11 "30"  13  "36", labsize(large))  order(${coeflist})   nooffsets ///
			yline(0, lstyle(major_grid)) ${yscale} vertical  levels(95) scheme(s1mono)    legend(off)  xtitle("Time of Unemployment spell", size(large))  connect(direct)  ytitle("${ytitle2}", size(large))   
graph export "Figure3_${Figure3num}_24months.png", replace	


coefplot 	(m10, color(black) msymbol(none)  label("no UI") keep(${coeflist}) lpattern(solid) lwidth(0.7) ciopts(recast(rconnected) lcolor(black) lpattern(line) lwidth(thin)   msymbol(none)  )  ) ///
			(m15, msymbol(none) color(blue)label("36 months UI") keep(${coeflist}) lpattern(solid) lwidth(0.7) ciopts(recast(rconnected) lcolor(blue) lpattern(line) lwidth(thin)   msymbol(none)  ) ) ,  omitted ///
			xline(13,lcolor(blue) lpattern(dash)) xlabel(3 "6"  5 "12" 7 "18"  9 "24" 11 "30"  13  "36", labsize(large))  order(${coeflist})      nooffsets ///
			yline(0, lstyle(major_grid)) ${yscale} vertical  levels(95) scheme(s1mono)  legend(off)  xtitle("Time of Unemployment spell", size(large))  connect(direct)  ytitle("${ytitle2}", size(large))   
graph export "Figure3_${Figure3num}_36months.png", replace	




end





******************************************************************************************************************************
***** with PBD FE *****************************************************************************************************
******************************************************************************************************************************




capture program drop Graph_withPBDFE
program Graph_withPBDFE

global coeflist "zero quarter_2 quarter_3 quarter_4 quarter_5 quarter_6 quarter_7 quarter_8 quarter_9 quarter_10 quarter_11 quarter_12 quarter_13"

    
set more off

preserve
keep if  PBD==0 ${cond}
xi : reghdfe ${var} ${coeflist}  , absorb(PBD)  vce(cluster spell_identifier)  
est store m20
restore

preserve
keep if  PBD==6 ${cond}
xi : reghdfe ${var} ${coeflist}  , absorb(PBD)  vce(cluster spell_identifier)  
est store m21
restore

preserve
keep if PBD==12 ${cond}
xi : reghdfe ${var} ${coeflist}   , absorb(PBD)  vce(cluster spell_identifier)  
est store m22
restore

preserve
keep if  PBD==24  ${cond}
xi : reghdfe ${var} ${coeflist}   , absorb(PBD)  vce(cluster spell_identifier)  
est store m24
restore

preserve
keep if  PBD==36  ${cond}
xi : reghdfe ${var} ${coeflist}   , absorb(PBD)  vce(cluster spell_identifier)  
est store m25
restore


coefplot 	(m20, color(black) msymbol(none) label("no UI")  keep(${coeflist}) lpattern(solid) lwidth(0.7) ciopts(recast(rconnected) lcolor(black) lpattern(line) lwidth(thin)   msymbol(none)  )  ) ///
			(m21, color(orange) msymbol(none)  lpattern(solid) label("6 months UI") keep(${coeflist})  lwidth(0.7) ciopts(recast(rconnected) lcolor(orange)  lpattern(solid) lwidth(thin)   msymbol(none)  ) ) ,  omitted ///
			xline(3,lcolor(orange) lpattern(dash)) xlabel(3 "6"  5 "12" 7 "18"  9 "24" 11 "30"  13  "36", labsize(large))   order(${coeflist})   ylabel( , labsize(large))  nooffsets ///
			yline(0, lstyle(major_grid)) ${yscale}  vertical  levels(95) scheme(s1mono)  legend(off) xtitle("Time of Unemployment spell", size(large))  connect(direct)  ytitle("${ytitle2}", size(large))   
graph export "Figure3_${Figure3num}_6months.png", replace	

coefplot 	(m20, color(black) msymbol(none) label("no UI")  keep(${coeflist}) lpattern(solid) lwidth(0.7) ciopts(recast(rconnected) lcolor(black) lpattern(line) lwidth(thin)   msymbol(none)  )  ) ///
			(m22, color(red) msymbol(none) lpattern(solid) label("12 months UI")  keep(${coeflist})  lwidth(0.7) ciopts(recast(rconnected) lcolor(red) lpattern(solid)  lwidth(thin)   msymbol(none)  ) ) ,  omitted ///
			xline(5,lcolor(red) lpattern(dash)) xlabel(3 "6"  5 "12" 7 "18"  9 "24" 11 "30"  13  "36", labsize(large))  order(${coeflist})  ylabel( , labsize(large))  nooffsets ///
			yline(0, lstyle(major_grid)) ${yscale}  vertical  levels(95) scheme(s1mono)  legend(off) xtitle("Time of Unemployment spell", size(large))  connect(direct)  ytitle("${ytitle2}", size(large))   
graph export "Figure3_${Figure3num}_12months.png", replace	


coefplot 	(m20, color(black) msymbol(none)  label("no UI")  keep(${coeflist}) lpattern(solid) lwidth(0.7) ciopts(recast(rconnected) lcolor(black) lpattern(line) lwidth(thin)   msymbol(none)  )  ) ///
			(m24, msymbol(none) color(purple) lpattern(solid) label("24 months UI")    keep(${coeflist}) lwidth(0.7) ciopts(recast(rconnected) lcolor(purple) lpattern(solid)  lwidth(thin)   msymbol(none)  ) ) ,  omitted ///
			 xline(9, lcolor(purple) lpattern(dash) ) xlabel(3 "6"  5 "12" 7 "18"  9 "24" 11 "30"  13  "36", labsize(large))  order(${coeflist})    ylabel( , labsize(large))  nooffsets ///
			yline(0, lstyle(major_grid)) ${yscale}  vertical  levels(95) scheme(s1mono)   legend(off) xtitle("Time of Unemployment spell", size(large))  connect(direct)  ytitle("${ytitle2}", size(large))   
graph export "Figure3_${Figure3num}_24months.png", replace	


coefplot 	(m20, color(black) msymbol(none) label("no UI")  keep(${coeflist}) lpattern(solid) lwidth(0.7) ciopts(recast(rconnected) lcolor(black) lpattern(line) lwidth(thin)   msymbol(none)  )  ) ///
			(m25, msymbol(none) color(blue) lpattern(solid) label("36 months UI")  keep(${coeflist})  lwidth(0.7) ciopts(recast(rconnected) lcolor(blue) lpattern(solid)  lwidth(thin)   msymbol(none)  ) ) ,  omitted ///
			xline(13, lcolor(blue) lpattern(dash) ) xlabel(3 "6"  5 "12" 7 "18"  9 "24" 11 "30"  13  "36", labsize(large))  order(${coeflist})  ylabel( , labsize(large))  nooffsets ///
			yline(0, lstyle(major_grid))  ${yscale}  vertical  levels(95) scheme(s1mono)  legend(off)  xtitle("Time of Unemployment spell", size(large)) connect(direct)   ytitle("${ytitle2}", size(large))   
graph export "Figure3_${Figure3num}_36months.png", replace	



end




*******************************************
**** Re-employment (Figure 2 (1)) *********
*******************************************

global Figure2num "(1)"
global var "Quarter_FirstJob"
global cond " "
global yscale "yscale(range(0 0.13)) ylabel(0(0.05)0.10 , labsize(large)) yline(0, lstyle(major_grid)) "
global sample "FullSample"
Graph_withoutFE

*******************************************
**** Re-employment wage  (Figure 2 (2)) ***
*******************************************

global Figure2num "(2)"
global var "last_explained_monthly_w2"
global yscale "yscale(range(1100 1450)) ylabel(1100(100)1450 , labsize(large))"
global cond "& Quarter_FirstJob >0"
global sample "FullSample"
Graph_withoutFE

*******************************************
************ Search effort ****************
*******************************************

global var "Count_Application"

* Full sample, without FE (Figure 2 (3))

global Figure2num "(3)"
global cond "  "
global sample "FullSample"
global legend "legend(off)"
global yscale "yscale(range(0 0.6)) ylabel(0(0.1)0.6 , labsize(large))"
Graph_withoutFE

* Full sample, Spell FE (Figure 2 (5) & Figure 3 (3))

global Figure2num "(5)"
global Figure3num "(3)"
global yscale "yscale(range(0 0.21)) ylabel(0(0.1)0.2 , labsize(large))"
Graph_withFE


* Full sample, PBD FE (Figure 3 (1))

global Figure3num "(1)"
global yscale "yscale(range(-0.5 0)) ylabel(-0.5(0.1)0 , labsize(large))"
Graph_withPBDFE

* Balanced sample, Spell FE (Figure 3 (5))

global Figure2num "(7)"
global Figure3num "(5)"
global cond "& balanced_sample==1"
global sample "BalancedSample"
global yscale "yscale(range(0 0.21)) ylabel(0(0.1)0.2 , labsize(large))"
global legend "legend(rows(1) symxsize(10) keygap(0.5) size(large))"
Graph_withFE

*******************************************
**** Target wage **************************
*******************************************

global var "explained_monthly_w"

* Full sample, without FE (Figure 2 (4))

global Figure2num "(4)"
global cond " "
global sample "FullSample"
global legend "legend(off)"
global yscale "yscale(range(1100 1450)) ylabel(1100(100)1450 , labsize(large))"
Graph_withoutFE

* Full sample, Spell FE (Figure 2 (6) & Figure 3 (4))

global Figure2num "(6)"
global Figure3num "(4)"
global yscale "yscale(range(-250 20)) ylabel(-200(100)20, labsize(large))"
Graph_withFE

* Full sample, PBD FE (Figure 3 (2))

global Figure3num "(2)"
global yscale "yscale(range(-250 20)) ylabel(-200(100)20, labsize(large))"
Graph_withPBDFE

* Balanced sample, Spell FE (Figure 3 (6))

global Figure2num "(8)"
global Figure3num "(6)"
global cond "& balanced_sample==1"
global sample "BalancedSample"
global legend "legend(rows(1) symxsize(10) keygap(0.5) size(large))"
Graph_withFE





